From 98854f6f7c9532f3e56c185ecab91e5edc12e6b9 Mon Sep 17 00:00:00 2001 From: Gabriel Souza Franco Date: Fri, 30 Jan 2015 12:36:24 -0200 Subject: [PATCH] Update log crate to v0.2 --- Cargo.lock | 17 ++++++++++++++++- Cargo.toml | 3 ++- src/bin/cargo.rs | 2 ++ src/cargo/core/registry.rs | 2 +- src/cargo/core/resolver/mod.rs | 10 +++++----- src/cargo/core/source.rs | 2 +- src/cargo/lib.rs | 2 +- src/cargo/ops/cargo_compile.rs | 2 +- src/cargo/ops/cargo_read_manifest.rs | 8 ++++---- src/cargo/ops/cargo_rustc/fingerprint.rs | 4 ++-- src/cargo/ops/cargo_rustc/job_queue.rs | 2 +- src/cargo/ops/cargo_rustc/mod.rs | 2 +- src/cargo/sources/git/source.rs | 4 ++-- src/cargo/sources/path.rs | 10 +++++----- src/cargo/sources/registry.rs | 2 +- 15 files changed, 45 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e637c168f..f722770d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,11 +5,12 @@ dependencies = [ "advapi32-sys 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.31 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)", - "log 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "registry 0.1.0", "rustc-serialize 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -65,6 +66,15 @@ dependencies = [ "rustc-serialize 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "env_logger" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "flate2" version = "0.1.6" @@ -156,6 +166,11 @@ dependencies = [ "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "log" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "matches" version = "0.1.2" diff --git a/Cargo.toml b/Cargo.toml index bf595de89..e691eddd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,8 @@ flate2 = "0.1" git2 = "0.1" glob = "0.1" time = "0.1" -log = "0.1" +log = "0.2" +env_logger = "0.2" docopt = "0.6" url = "0.2" rustc-serialize = "0.2" diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index f39b6d008..83dfaecd2 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -3,6 +3,7 @@ extern crate "rustc-serialize" as rustc_serialize; extern crate cargo; #[macro_use] extern crate log; +extern crate env_logger; use std::collections::BTreeSet; use std::os; @@ -49,6 +50,7 @@ See 'cargo help ' for more information on a specific command. "; fn main() { + env_logger::init().unwrap(); execute_main_without_stdin(execute, true, USAGE) } diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 281e097f7..0a9c0c96b 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -80,7 +80,7 @@ impl<'a, 'b> PackageRegistry<'a, 'b> { } pub fn get(&mut self, package_ids: &[PackageId]) -> CargoResult> { - log!(5, "getting packages; sources={}", self.sources.len()); + trace!("getting packages; sources={}", self.sources.len()); // TODO: Only call source with package ID if the package came from the // source diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 10c81338e..223afa784 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -131,7 +131,7 @@ struct Context { /// Builds the list of all packages required to build the first argument. pub fn resolve(summary: &Summary, method: Method, registry: &mut Registry) -> CargoResult { - log!(5, "resolve; summary={}", summary.get_package_id()); + trace!("resolve; summary={}", summary.get_package_id()); let summary = Rc::new(summary.clone()); let cx = Box::new(Context { @@ -251,9 +251,9 @@ fn activate_deps<'a>(cx: Box, let key = (dep.get_name().to_string(), dep.get_source_id().clone()); let prev_active = cx.activations.get(&key) .map(|v| v.as_slice()).unwrap_or(&[]); - log!(5, "{}[{}]>{} {} candidates", parent.get_name(), cur, dep.get_name(), + trace!("{}[{}]>{} {} candidates", parent.get_name(), cur, dep.get_name(), candidates.len()); - log!(5, "{}[{}]>{} {} prev activations", parent.get_name(), cur, + trace!("{}[{}]>{} {} prev activations", parent.get_name(), cur, dep.get_name(), prev_active.len()); // Filter the set of candidates based on the previously activated @@ -283,7 +283,7 @@ fn activate_deps<'a>(cx: Box, // each one in turn. let mut last_err = None; for candidate in my_candidates { - log!(5, "{}[{}]>{} trying {}", parent.get_name(), cur, dep.get_name(), + trace!("{}[{}]>{} trying {}", parent.get_name(), cur, dep.get_name(), candidate.get_version()); let mut my_cx = cx.clone(); my_cx.resolve.graph.link(parent.get_package_id().clone(), @@ -304,7 +304,7 @@ fn activate_deps<'a>(cx: Box, Err(e) => { last_err = Some(e); } } } - log!(5, "{}[{}]>{} -- {:?}", parent.get_name(), cur, dep.get_name(), + trace!("{}[{}]>{} -- {:?}", parent.get_name(), cur, dep.get_name(), last_err); // Oh well, we couldn't activate any of the candidates, so we just can't diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index b7c1c02a0..089a38890 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -193,7 +193,7 @@ impl SourceId { /// Creates an implementation of `Source` corresponding to this ID. pub fn load<'a>(&self, config: &'a Config) -> Box { - log!(5, "loading SourceId; {}", self); + trace!("loading SourceId; {}", self); match self.inner.kind { Kind::Git(..) => Box::new(GitSource::new(self, config)) as Box, Kind::Path => { diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 6875c41c0..895200b06 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -141,7 +141,7 @@ fn output(err: String, shell: &mut MultiShell, fatal: bool) { } pub fn handle_error(err: CliError, shell: &mut MultiShell) { - log!(4, "handle_error; err={:?}", err); + debug!("handle_error; err={:?}", err); let CliError { error, exit_code, unknown } = err; let fatal = exit_code != 0; // exit_code == 0 is non-fatal error diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 857c2094a..a0fea0f37 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -56,7 +56,7 @@ pub struct CompileOptions<'a, 'b: 'a> { pub fn compile(manifest_path: &Path, options: &CompileOptions) -> CargoResult { - log!(4, "compile; manifest-path={}", manifest_path.display()); + debug!("compile; manifest-path={}", manifest_path.display()); let mut source = try!(PathSource::for_path(&manifest_path.dir_path(), options.config)); diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 7bfefa095..27c8c42aa 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -20,7 +20,7 @@ pub fn read_manifest(contents: &[u8], layout: Layout, source_id: &SourceId, pub fn read_package(path: &Path, source_id: &SourceId, config: &Config) -> CargoResult<(Package, Vec)> { - log!(5, "read_package; path={}; source-id={}", path.display(), source_id); + trace!("read_package; path={}; source-id={}", path.display(), source_id); let mut file = try!(File::open(path)); let data = try!(file.read_to_end()); @@ -36,10 +36,10 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config) let mut all_packages = HashSet::new(); let mut visited = HashSet::::new(); - log!(5, "looking for root package: {}, source_id={}", path.display(), source_id); + trace!("looking for root package: {}, source_id={}", path.display(), source_id); try!(walk(path, |dir| { - log!(5, "looking for child package: {}", dir.display()); + trace!("looking for child package: {}", dir.display()); // Don't recurse into git databases if dir.filename_str() == Some(".git") { return Ok(false); } @@ -78,7 +78,7 @@ fn walk_inner(path: &Path, callback: &mut F) -> CargoResult<()> if path.is_dir() { let continues = try!(callback(path)); if !continues { - log!(5, "not processing {}", path.display()); + trace!("not processing {}", path.display()); return Ok(()); } diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 96d8ed99d..297173a31 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -322,8 +322,8 @@ fn is_fresh(loc: &Path, new_fingerprint: &Fingerprint) -> CargoResult { Err(..) => return Ok(false), }; - log!(5, "old fingerprint: {}", old_fingerprint); - log!(5, "new fingerprint: {}", new_fingerprint); + trace!("old fingerprint: {}", old_fingerprint); + trace!("new fingerprint: {}", new_fingerprint); Ok(old_fingerprint.as_slice() == new_fingerprint) } diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 9e09e73ef..65e37661d 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -151,7 +151,7 @@ impl<'a, 'b> JobQueue<'a, 'b> { } } - log!(5, "rustc jobs completed"); + trace!("rustc jobs completed"); Ok(()) } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index bc91c325b..f5a2a16bb 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -528,7 +528,7 @@ fn rustdoc(package: &Package, target: &Target, None }); - log!(5, "commands={}", rustdoc); + trace!("commands={}", rustdoc); let primary = package.get_package_id() == cx.resolve.root(); let name = package.get_name().to_string(); diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 405590dea..24470e591 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -172,7 +172,7 @@ impl<'a, 'b> Source for GitSource<'a, 'b> { try!(self.config.shell().status("Updating", format!("git repository `{}`", self.remote.get_url()))); - log!(5, "updating git source `{:?}`", self.remote); + trace!("updating git source `{:?}`", self.remote); let repo = try!(self.remote.checkout(&self.db_path)); let rev = try!(repo.rev_for(&self.reference)); (repo, rev) @@ -197,7 +197,7 @@ impl<'a, 'b> Source for GitSource<'a, 'b> { } fn get(&self, ids: &[PackageId]) -> CargoResult> { - log!(5, "getting packages for package ids `{:?}` from `{:?}`", ids, + trace!("getting packages for package ids `{:?}` from `{:?}`", ids, self.remote); self.path_source.as_ref().expect("BUG: update() must be called \ before get()").get(ids) diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index ff1538d43..a8ef8b5c9 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -21,7 +21,7 @@ pub struct PathSource<'a, 'b: 'a> { impl<'a, 'b> PathSource<'a, 'b> { pub fn for_path(path: &Path, config: &'a Config<'b>) -> CargoResult> { - log!(5, "PathSource::for_path; path={}", path.display()); + trace!("PathSource::for_path; path={}", path.display()); Ok(PathSource::new(path, &try!(SourceId::for_path(path)), config)) } @@ -30,7 +30,7 @@ impl<'a, 'b> PathSource<'a, 'b> { /// in the directory structure reachable by the root manifest. pub fn new(path: &Path, id: &SourceId, config: &'a Config<'b>) -> PathSource<'a, 'b> { - log!(5, "new; id={}", id); + trace!("new; id={}", id); PathSource { id: id.clone(), @@ -42,7 +42,7 @@ impl<'a, 'b> PathSource<'a, 'b> { } pub fn get_root_package(&self) -> CargoResult { - log!(5, "get_root_package; source={:?}", self); + trace!("get_root_package; source={:?}", self); if !self.updated { return Err(internal("source has not been updated")) @@ -239,7 +239,7 @@ impl<'a, 'b> Source for PathSource<'a, 'b> { } fn get(&self, ids: &[PackageId]) -> CargoResult> { - log!(5, "getting packages; ids={:?}", ids); + trace!("getting packages; ids={:?}", ids); Ok(self.packages.iter() .filter(|pkg| ids.iter().any(|id| pkg.get_package_id() == id)) @@ -262,7 +262,7 @@ impl<'a, 'b> Source for PathSource<'a, 'b> { warn!("{} {}", file.stat().map(|s| s.modified).unwrap_or(0), file.display()); max = cmp::max(max, file.stat().map(|s| s.modified).unwrap_or(0)); } - log!(5, "fingerprint {}: {}", self.path.display(), max); + trace!("fingerprint {}: {}", self.path.display(), max); Ok(max.to_string()) } } diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs index ef41471cd..a613ddbcf 100644 --- a/src/cargo/sources/registry.rs +++ b/src/cargo/sources/registry.rs @@ -453,7 +453,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> { // git reset --hard origin/master let reference = "refs/remotes/origin/master"; let oid = try!(repo.refname_to_id(reference)); - log!(5, "[{}] updating to rev {}", self.source_id, oid); + trace!("[{}] updating to rev {}", self.source_id, oid); let object = try!(repo.find_object(oid, None)); try!(repo.reset(&object, git2::ResetType::Hard, None, None, None)); self.updated = true; -- 2.30.2